package es.christiangarcia.android.pokepedia.business;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import es.christiangarcia.android.pokepedia.dao.PokemonDAO;
import es.christiangarcia.android.pokepedia.model.Pokemon;
import es.christiangarcia.android.pokepedia.model.vo.PokemonVO;

public class PokemonBO {

	private PokemonDAO pokemonDAO;

	public PokemonBO(Context context) {
		this.pokemonDAO = new PokemonDAO(context);
	}

	public Pokemon getPokemonByNum(int num) {
		for (Pokemon pokemon : this.getAllPokemons()) {
			if (num == pokemon.getNum()) {
				return pokemon;
			}
		}
		return null;

	}

	public List<Pokemon> getAllPokemons() {
		List<Pokemon> pokemons = new ArrayList<Pokemon>();
		List<PokemonVO> dbPokemons = this.pokemonDAO.getAllPokemonVOs();
		for (PokemonVO dbPokemon : dbPokemons) {
			Pokemon pokemon = dbPokemonToPokemon(dbPokemon);
			pokemons.add(pokemon);
		}
		return pokemons;
	}

	private Pokemon dbPokemonToPokemon(PokemonVO dbPokemon) {
		return null;
	}
	
	public Context getContext(){
		return this.pokemonDAO.getContext();
	}

}
